<!-- 采购订单详情 -->
<template>
  <div class="my-invoice-detail">  
    <row title="订单号"  :value="detail.orderSn"></row>
    <row title="下单时间"  :value="detail.addTime"></row>
    <row title="订单金额"  :value="'￥'+detail.orderPrice"></row> 
    <div class="invoice-photo">
        <div class="map-title">订单商品</div>
         <div class="goods-list" v-for="(item,index) in goodsList" :key="index">
            <div class="goods-left">
                <img :src="item.picUrl" alt="" class="goods-img">
            </div>
            <div class="goods-right">
                <div class="goods-name">{{item.goodsName}}</div>
                <div class="goods-price"><span>单价:</span>￥{{item.price}}</div>
                <div class="goods-num"><span>数量(箱):</span>{{item.number}}</div>
            </div>
         </div>
    </div>
    <row title="下单人"  :value="detail.consignee"></row>
    <row title="收货地址" v-if="detail.address" :value="detail.address"></row>
    <row title="收货店铺" v-if="detail.storeName"  :value="detail.storeName"></row>
    <row title="收货仓库" v-if="detail.replWarehouseName"  :value="detail.replWarehouseName"></row>
    <row title="状态"  :value="detail.orderStatusText"></row>
    <div class="height120"></div>
     <div class="btn-box"  v-if="detail.orderStatus==301 || detail.orderStatus==101 || detail.orderStatus==100 || detail.orderStatus==101">    
       <div class="isbtn rightline"  v-if="detail.orderStatus==301" @click="optOrders(1)">确认收货</div>
       <div class="isbtn rightline" v-if="detail.orderStatus==101 || detail.orderStatus==100"  @click="optOrders(2)">取消订单</div>
       <div class="isbtn rightline" v-if="detail.orderStatus==101" @click="optOrders(3)">我已付款</div>
    </div> 
  </div>
</template>

<script>
import row from '@/components/row' 
import api from '@/api/api.js' 
import { Message } from 'element-ui' 
export default { 
  components: {
    row,
    goIndex
  },
  data () {
    return {
      goodsList:[], 
      detail:{
      }
    }
  },
  watch:{ 
    seriesData: {
      deep: true,
      handler(val) { 
        console.log(val)
      }
    } 
  },
  created(){
    this.getDetail();
  }, 
  mounted () {

  },
  filters: {
     
  },
  methods: { 
    optOrders(idx){
        this.$vux.confirm.show({
        title: '提示',
        content: '确认操作？', 
        onCancel () { 
        },
        onConfirm: ()=> {
          if(idx == 1){ // 确认收货
            api.orderMng.orderConfirm({
              orderId:this.$route.query.id
            },res=>{
              this.getDetail();
              return  Message({
                message: "更新成功",
                type: 'success',
                duration: 1 * 1000
              }) 
            }) 
          }else if(idx == 2){ // 取消
            api.orderMng.cancelOrder({
              orderId:this.$route.query.id
            },res=>{
              this.getDetail();
              return  Message({
                message: "更新成功",
                type: 'success',
                duration: 1 * 1000
              }) 
            }) 
          }else if(idx == 3){ //我已付款
            api.orderMng.paySuccess({
              orderId:this.$route.query.id
            },res=>{
              this.getDetail();
              return  Message({
                message: "更新成功",
                type: 'success',
                duration: 1 * 1000
              })
            }) 
            
          }
        }
      })
    },
    getDetail(){
        api.orderMng.orderDetail({
            orderId:this.$route.query.id
        },res=>{
            this.goodsList = res.result.orderGoods;
            this.detail = res.result.orderInfo
        }) 
    },
    cancelOrder(){
        
    }
  }
}
</script>
<style lang="less" scoped>
.invoice-photo{
    padding: 12px 16px;
}
.map-title{
    height: 40px;
    line-height: 40px;
    font-size: 16px;
    font-weight: bold;
}
.invoice-order{
    display: flex;
    height: 40px;
    line-height: 40px; 
}
.height120{
    height: 1.2rem;
}
.goods-list{
    display: flex;
    padding: .20rem 0;
    position: relative;
    &::before{
        position: absolute;
        bottom: 0;
        content: '';
        left: 0;
        right: -20px;
        height: 1px;
        background: #f5f5f5;
    }
}
.btn-box{
    display: flex;
    background: #fff;
    height: 50px;
    box-sizing: border-box;
    position: fixed;
    box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.06);;
    bottom: 0;
    left: 0;
    right: 0;
    &>div{
        flex: 1;
        text-align: center;
        line-height: 50px;
    }
    .rightline{
        position: relative;
        &::before{
            content: '';
            right: 0;
            top: 18px;
            position: absolute;
            bottom: 18px;
            width: 1px;
            background: #e1e1e1;
        }
    }

}
.goods-img{
    width: 1.48rem;
    height: 1.48rem;
    border-radius: .12rem;
    background: #ddd;
}
.goods-name{
    font-size: .30rem;
    font-weight: bold;
    line-height: .34rem;
}
.goods-price,.goods-num{
    
    font-size: .24rem;
    & span{
        margin-right: .12rem;
        color: #999;
    }
}
.goods-right{
    width: 1.48rem;
    height: 1.48rem;
    flex: 1;
    padding-left: .20rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.invoice-number{
    color: #444;
    width: 35%;
    padding-left: 8px;
}
.tips{
    color: #999;
    font-size: 11px;
    margin-left: 8px;
}
.invoice-money{
    color: #999;
    width: 30%;
}
.invoice-timer{
   color: #666; 
   width: 35%;
}
.invoice-active{
    background: #e1e1e1;
}
.wrap-box{
    display: flex;
    flex-wrap: wrap;
    img{
        margin-bottom: 10px;
        margin-right: 10px;
        width: 74px;
        height: 74px;
        background: #bbb;    }
}
.btn-box{
    display: flex;
    background: #fff;
    height: 50px;
    box-sizing: border-box;
    position: fixed;
    box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.06);;
    bottom: 0;
    left: 0;
    right: 0;
    &>div{
        flex: 1;
        text-align: center;
        line-height: 50px;
    }
    .rightline{
        position: relative;
        &::before{
            content: '';
            right: 0;
            top: 18px;
            position: absolute;
            bottom: 18px;
            width: 1px;
            background: #e1e1e1;
        }
    }

}
</style>
